<template>
  <div class="user">
    <!-- 用户信息 -->
    <van-cell-group>
      <van-cell class="user-info" :border="false">
        <van-image
          width="50"
          height="50"
          round
          :src="userInfo.portrait || 'https://edu-lagou.oss-cn-beijing.aliyuncs.com/images/2020/07/10/15943594999396473.png'"
        />
        <div class="user-info-content">
          <h3>{{userInfo.userName}}</h3>
          <span >
            <van-icon name="edit"/>
            编辑用户信息
          </span>
        </div>
      </van-cell>
      <van-cell class="account-info">
        <van-grid>
          <van-grid-item>
            <span class="account-info-value">140.5</span>
            <span>学习时长</span>
          </van-grid-item>
          <van-grid-item>
            <span class="account-info-value">200</span>
            <span>钱包/勾豆</span>
          </van-grid-item>
          <van-grid-item>
            <span class="account-info-value">1</span>
            <span>优惠券</span>
          </van-grid-item>
          <van-grid-item>
            <span class="account-info-value">213</span>
            <span>学分</span>
          </van-grid-item>
        </van-grid>
      </van-cell>
      <van-cell icon="user-o" title="分销中心" is-link value="收益200元" />
      <van-cell icon="setting-o" title="个性化设置" is-link  />
      <van-cell icon="down" title="我的下载" is-link  />
      <van-cell icon="question-o" title="帮助与反馈" is-link />
      <van-cell icon="info-o" title="关于拉勾教育" is-link value="v2.0.0" />
    </van-cell-group>
    <!-- 底部导航栏 -->
    <layout-footer></layout-footer>
  </div>
</template>

<script>
import { CellGroup, Cell, Grid, GridItem, Icon, Image } from 'vant'
import { getInfo } from '@/services/user'
import LayoutFooter from '@/components/LayoutFooter.vue'
export default {
  components: {
    LayoutFooter,
    VanCellGroup: CellGroup,
    VanCell: Cell,
    VanGrid: Grid,
    VanGridItem: GridItem,
    VanIcon: Icon,
    VanImage: Image
  },
  name: 'User',
  created () {
    this.loadUserInfo()
  },
  data () {
    return {
      userInfo: {}
    }
  },
  methods: {
    async loadUserInfo () {
      const { data } = await getInfo()
      console.log(data)
      if (data.state === 1) {
        this.userInfo = data.content
      }
    }
  }
}
</script>

<style  scoped>
.van-cell__value {
  height: auto;
}
.user-info .van-cell__value {
  display: flex;
}
.user-info {
  padding: 30px 20px 0;
  background-color: orange;
}
.user-info-content {
  padding-left: 15px;
}
.user-info-content h3 {
  margin: 5px;
  font-size: 18px;
}
.van-image {
  margin: 0;
}
.van-image img {
  width: 100%;
}
.account-info {
  margin-top: -1px;
  background-color: orange;
}
.van-grid {
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
}
.account-info-value {
  font-size: 20px;
  font-weight: 700;
}
</style>>
